package com.conversationboard.validate.bbcode;

public class BbTagFormatException extends Exception {

    private static final long serialVersionUID = 4976055743302911416L;
    String sourceText = "";
    String errorExplanation = "";
    int errorOffset = -1;


    public BbTagFormatException(String error, int offset, String explanation) {
        super(error);
        sourceText = error;
        errorOffset = offset;
        errorExplanation = explanation;
    }


    public BbTagFormatException(String error, int offset) {
        super(error);
        sourceText = error;
        errorOffset = offset;
    }


    /*
     * Returns an array of 2 strings: The first is sourceText prior to the error
     * and the second is sourceText after the error.
     */
    public String[] getErrorContext() {
        String[] errCtx = { sourceText.substring(0, errorOffset), sourceText.substring(errorOffset, sourceText.length()) };
        return errCtx;
    }


    public String getErrorExplanation() {
        return errorExplanation;
    }


    public void setErrorExplanation(String error) {
        errorExplanation = error;
    }
}